<?php
    use User\Model\ApplicationsModel;
?>
<!-- page heading start-->
<div class="page-heading">
    <h3>
        信息分类
    </h3>

</div>
<!-- page heading end-->
<div class="row">
    <div class="col-sm-12">
        <section class="panel">
            <header class="panel-heading">
                <form class="form-horizontal" action="<?php echo '/User/Applications/xxfl';?>">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">开始时间:</label>

                        <div class="col-lg-3">
                            <input class="form-control date-picker" autocomplete="off" name="start_date"
                                   value="<?php echo I('get.start_date', '', '');?>" placeholder="请输入开始时间">
                        </div>

                        <label class="col-sm-2 control-label">结束时间:</label>

                        <div class="col-lg-3">
                            <input class="form-control date-picker" autocomplete="off" name="end_date"
                                   value="<?php echo I('get.end_date', '', '');?>" placeholder="请输入结束时间">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">状态:</label>
                        <div class="col-lg-3">
                            <select class="form-control" name="status">
                                <option value="0" <?php
                                $status = I('get.status', '', '');
                                if($status == 0){
                                    echo " selected";
                                }
                                ?>>全部</option>
                                <option value="1" <?php
                                $status = I('get.status', '', '');
                                if($status == 1){
                                    echo " selected";
                                }
                                ?>>未导出</option>
                                <option value="2" <?php
                                $status = I('get.status', '', '');
                                if($status == 2){
                                    echo " selected";
                                }
                                ?>>已导出</option>
                            </select>
                        </div>
                        <label class="col-sm-2 control-label">电话:</label>
                        <div class="col-lg-3">
                            <input class="form-control" name="phone" value="<?php echo I('get.phone', '', '');?>">
                        </div>
                        <button class="btn btn-success" type="submit">查询</button>
                        <a class="btn btn-default" onclick="clean_up();">清空</a>
                    </div>
                </form>
            </header>
            <div class="panel-body">
                <button class="btn btn-primary" onclick="download();">导出</button>
                <table class="table table-hover general-table table-bordered">
                    <thead>
                    <tr>
                        <th width="8%">姓名</th>
                        <th width="10%">电话</th>
                        <th width="15%">配送地址</th>
                        <th width="10%">广告类型</th>
                        <th width="25%">描述</th>
                        <th width="10%">状态</th>
                        <th width="10%">提交时间</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php foreach($list as $val){?>
                    <tr>
                        <td>
                            <span style="word-break:break-all;word-wrap:break-word">
                                <?php echo $val['name'];?>
                            </span>
                        </td>
                        <td>
                            <span style="word-break:break-all;word-wrap:break-word">
                                <?php echo $val['phone'];?>
                            </span>
                        </td>
                        <td>
                            <span style="word-break:break-all;word-wrap:break-word">
                                <?php echo $val['delivery'] ? "自取" : $val['address'];?>
                            </span>
                        </td>
                        <td>
                            <span style="word-break:break-all;word-wrap:break-word">
                                <?php echo $val['type'] ? "个人刊登--" : "公司刊登--";
                                echo ApplicationsModel::getAdName($val['typed']);
                                ?>
                            </span>
                        </td>
                        <td>
                            <span style="word-break:break-all;word-wrap:break-word">
                                <?php
                                echo $val['desc'];
                            ?>
                            </span>
                        </td>
                        <td>
                            <span style="word-break:break-all;word-wrap:break-word">
                                <?php
                                if($val['status'] == 1){
                                    echo "已导出";
                                }else{
                                    echo "未导出";
                                }
                            ?>
                            </span>
                        </td>
                        <td>
                            <span style="word-break:break-all;word-wrap:break-word">
                                <?php
                                echo $val['create_date'];
                            ?>
                            </span>
                        </td>
                        <td>
                            <div>
                                <a class="btn btn-danger" href="#"
                                   onclick="<?php echo 'return delete_data(' . $val['id'] .')';?>">删除</a>
                            </div>
                        </td>
                    </tr>
                    <?php }?>

                    </tbody>
                </table>
                <div class="pages">
                    {$page}
                </div>
            </div>
        </section>
    </div>
</div>
<script>
    function delete_data(id){
        $.ajax({
            data:{
                id:id,
                name:'xxfl_order'
            },
            dataType:'json',
            url:'/User/Applications/delete',
            type:'get',
            success:function(res){
                window.location.reload();
            }
        });
        return false;
    }
    function download(){
        if(confirm("确定导出？")) {
            window.location = '/User/Applications/exportXxfl?start_date=' + "<?php echo I('get.start_date', '', '');?>"
                + "&end_date=" + "<?php echo I('get.end_date', '', '');?>" + "&status=" + "<?php echo I('get.status', '', '');?>"
                + "&phone=" + "<?php echo I('get.phone', '', '');?>" ;
        }
        return false;
    }
    function clean_up(){
        window.location = "/User/Applications/xxfl";
        return false;
    }
</script>
<script type="text/javascript" src="/Public/js/laydate/laydate.js"></script>
<script type="text/javascript">
    $( ".date-picker" ).bind( "click", function(){
        laydate( {
            format: 'YYYY/MM/DD hh:mm:ss',
            min: laydate.now(), //设定最小日期为当前日期
            max: '2099-06-16 23:59:59', //最大日期
            istime: true,
            istoday: false
        } );
        laydate.skin( "molv" );
    });
</script>